/*------------------------------初始化数据部分开始----------------------*/
var isCanEdit = true;//设置是否可以编辑次级分类、查询标识
var isCanSearch = true;//设置是否可以编辑一级聚合级分类、查询标识
var currenTsource //当前端口
var sources=""
var warehouses=JSON.parse(sessionStorage.getItem("warehouses"))
for(var i=0;i<warehouses.data.length;i++){
    if(warehouses.data[i].warehouseDataType !=2){
    if(warehouses.data[i].warehouseAliasName=='北京'){
        $("#area_type").append("<option value=" + warehouses.data[i].warehouseCode + " selected>" + warehouses.data[i].warehouseAliasName + "DC覆盖</option>")
    }else {
        $("#area_type").append("<option value=" + warehouses.data[i].warehouseCode + ">" + warehouses.data[i].warehouseAliasName + "DC覆盖</option>")
    }
}
}
searchCate();
function searchFirstCate() {
    $("#click").attr({"disabled":"disabled"});
    $.ajax({
        contentType: 'application/json',
        url: root.category.category_listFirstDisplay,
        cache: false,  //禁用缓存
        type: "POST",
        data: JSON.stringify({
            source: $("#port_type").val(),
            platform: 10,
            warehouse: 1,
        }),
        success: function (data) {
            if(data.errorCode==0){
                $("#click").removeAttr("disabled")
                currenTsource=$("#port_type").val()
                $("#datatable tbody").html("");
                for (var i=0;i<data.data.length;i++){
                    var relationFirstLevel = "";//关联的一级分类
                    if(data.data[i].relationFirstLevelObject){
                        for(var j=0;j<data.data[i].relationFirstLevelObject.length;j++){
                            relationFirstLevel += "【"+data.data[i].relationFirstLevelObject[j].fristCategoryName+"】";
                        }
                    }else {
                        relationFirstLevel = "";
                    }
                    $("#datatable tbody").append("<tr><td><img onclick='picShow(\"查看图片\",\"../../goods/picShow.html\",\"" + data.data[i].pictureUrl + "\")' src='"+data.data[i].pictureUrl+"' alt='' width='50'></td><td>"+data.data[i].displayContent+"</td><td>"+relationFirstLevel+"</td><td class='operateTd'><span class='frontFirstCategoryId hide'>"+data.data[i].frontFirstCategoryId+"</span><input type='text' class='input-text w-50 togetherSort text-c' oninput = 'value=value.replace(/[^0-9]/g,\"\")' onblur='checksort(this,this.value,15)' value='"+data.data[i].showSequence+"' readonly>&nbsp<a class='powerButton 228' onclick='category_edit("+JSON.stringify(data.data[i])+","+data.data[i].source+")'>编辑</a></td></tr>");
                }
                //权限控制函数
                power()
            }

        }
    });
}
//图片展示
function picShow(title, url, imgUrl) {
    window.event ? window.event.cancelBubble = true : e.stopPropagation();
    sessionStorage.setItem("imgUrl", imgUrl);
    layer_show(title, url, "800", "500");
}
//排序输入数字判断
function checksort(el,val,max) {
    if(val==0){
        el.value = 1;
        layer.msg("排序序号最小为1", {icon: 5, time: 3000});
    }else if(val>max){
        el.value = max;
        layer.msg("排序序号最大为"+max, {icon: 5, time: 3000});
    }
}

function searchSubCate() {
    $("#click").attr({"disabled":"disabled"});
    $.ajax({
        contentType: 'application/json',
        url: root.category.category_listFrontCategory,
        cache: false,  //禁用缓存
        type: "POST",
        data: JSON.stringify({
            afterCategoryId:"",
            categoryLevel:"",
            source: $("#port_type").val(),
            platform: 10,
            warehouse: 1,
        }),
        success: function (data) {
            if(data.errorCode==0){
                $("#click").removeAttr("disabled")
                $(".level1-box").html("");
                var level1List = data.data;
                for(var i=0;i<level1List.length;i++){
                    var level2Html = '';
                    var level2List = level1List[i].secondList;
                    if(level2List){
                        for(var j=0;j<level2List.length;j++){
                            var level3Html = '';
                            var level3List = level2List[j].secondList;
                            if(level3List){
                                for(var k=0;k<level3List.length;k++){
                                    var checkedStr3 = "";
                                    if(level3List[k].status==10){
                                        checkedStr3 = "checked";
                                    }else {
                                        checkedStr3 = "";
                                    }
                                    level3Html += '<div class="level3-content">' +
                                        '                                        <ul class="clearfix" style="width: 100%">' +
                                        '                                            <li class="f-l text-c" style="width:11.5%"></li>' +
                                        '                                            <li class="f-l text-c" style="width:14%"></li>' +
                                        '                                            <li class="f-l text-c" style="width:10%"></li>' +
                                        '                                            <li class="f-l text-c" style="width:13%"></li>' +
                                        '                                            <li class="f-l text-c" style="width:10%"><span class="ml-5 category-name">'+level3List[k].afterCategoryName+'</span><span class="ml-5 category-id hide">'+level3List[k].afterCategoryId+'</span><span class="ml-5 category-level hide">'+level3List[k].categoryLevel+'</span></li>' +
                                        '                                            <li class="f-l text-c" style="width:13%">' +
                                        '                                                <span class="show-category-name">'+dealNull(level3List[k].fristCategoryName)+'</span>' +
                                        '                                                <i class="Hui-iconfont f-16 c-primary change_third do-edit" style="display: none" onclick="changeFirst(this)">&#xe6df;</i>' +
                                        '                                               <b class="remove-showName" style="display: none"><i class="Hui-iconfont c-primary f-16 va-m"  onclick="removeFirst(this)">&#xe6a6;</i></b>' +
                                        '                                                <input type="text" class="input-text w-80" maxlength="15" style="display: none" value="'+dealNull(level3List[k].fristCategoryName)+'">' +
                                        '                                                <span class="edit-btn-box" style="display: none"><i class="Hui-iconfont ml-10 iconsave c-primary f-16 va-m" onclick="saveFirst(this)">&#xe6a7;</i><i class="Hui-iconfont c-primary f-16 va-m iconcancel" onclick="cancelFirst(this)">&#xe6a6;</i></span>' +
                                        '                                            </li>' +
                                        '                                            <li class="f-l text-c category-show" style="width:8%"><input type="checkbox" class="checkbox level3-checkBox" '+checkedStr3+' disabled></li>' +
                                        '                                            <li class="f-l text-c category-sort" style="width:6%"><input type="text" class="input-text w-50 level3Sort text-c" oninput = "value=value.replace(/[^0-9]/g,\'\')" onblur="checksort(this,this.value,100)" value="'+level3List[k].showSequence+'" readonly></li>' +
                                        '                                            <li class="f-l text-c" style="width:14.5%"></li>' +
                                        '                                        </ul>' +
                                        '                                    </div>';
                                }
                            }
                            var checkedStr2 = "";
                            if(level2List[j].status==10){
                                checkedStr2 = "checked";
                            }else {
                                checkedStr2 = "";
                            }
                            level2Html += '<div class="level2">' +
                                '                                <div class="level2-content category-contents">' +
                                '                                    <ul class="clearfix" style="width: 100%">' +
                                '                                        <li class="f-l text-c" style="width:11.5%"></li>' +
                                '                                        <li class="f-l text-c" style="width:14%"></li>' +
                                '                                        <li class="f-l text-l" style="width:10%">' +
                                '                                            <button type="button" class="va-m text-c index_second ml-10" style="width:20px;height:20px" onclick="level3_show(this)">+</button>' +
                                '                                            <span class="ml-5 category-name">'+level2List[j].afterCategoryName+'</span>' +
                                '                                            <span class="ml-5 category-id hide">'+level2List[j].afterCategoryId+'</span>' +
                                '                                            <span class="ml-5 category-level hide">'+level2List[j].categoryLevel+'</span>' +
                                '                                        </li>' +
                                '                                        <li class="f-l text-c" style="width:13%">' +
                                '                                            <span class="show-category-name">'+dealNull(level2List[j].fristCategoryName)+'</span>' +
                                '                                            <i class="Hui-iconfont f-16 c-primary change_second do-edit" style="display: none" onclick="changeFirst(this)">&#xe6df;</i><b class="remove-showName" style="display: none"><i class="Hui-iconfont c-primary f-16 va-m" onclick="removeFirst(this)">&#xe6a6;</i></b>' +
                                '                                            <input type="text" class="input-text w-80" maxlength="15" style="display: none" value="'+dealNull(level2List[j].fristCategoryName)+'">' +
                                '                                            <span class="edit-btn-box" style="display: none"><i class="Hui-iconfont ml-10 iconsave c-primary f-16 va-m" onclick="saveFirst(this)">&#xe6a7;</i><i class="Hui-iconfont iconcancel c-primary f-16 va-m" onclick="cancelFirst(this)">&#xe6a6;</i></span>' +
                                '                                        </li>' +
                                '                                        <li class="f-l text-c" style="width:10%"></li>' +
                                '                                        <li class="f-l text-c" style="width:13%"></li>' +
                                '                                        <li class="f-l text-c category-show" style="width:8%"><input type="checkbox" class="checkbox level2-checkBox" '+checkedStr2+' disabled></li>' +
                                '                                        <li class="f-l text-c category-sort" style="width:6%"><input type="text" class="input-text w-50 level2Sort text-c" oninput = "value=value.replace(/[^0-9]/g,\'\')" onblur="checksort(this,this.value,100)" value="'+level2List[j].showSequence+'" readonly></li>' +
                                '                                        <li class="f-l text-c" style="width:14.5%">' +
                                '                                            <input type="button" class="btn btn-secondary size-S radius edit-third-btn powerButton 494" value="编辑三级品类" onclick="edit_thirdcate(this)">' +
                                '                                            <input type="button" class="btn btn-secondary size-S radius save-third-btn" value="保存" style="display:none" onclick="save_thirdcate(this)">' +
                                '                                            <input type="button" class="btn size-S radius cancel-third-btn" value="取消" style="display:none" onclick="cancel_thirdcate(this)">' +
                                '                                        </li>' +
                                '                                    </ul>' +
                                '                                </div>' +
                                '                                <div class="level3-box" style="display: none">' +level3Html+
                                '                                </div>' +
                                '                            </div>';
                        }
                    }
                    var checkedStr1 = "";
                    if(level1List[i].status==10){
                        checkedStr1 = "checked";
                    }else {
                        checkedStr1 = "";
                    }

                    $(".level1-box").append('<div class="level1">' +
                        '                        <div class="level1-content category-contents">' +
                        '                            <ul class="clearfix" style="width: 100%">' +
                        '                                <li class="f-l text-l" style="width:11.5%">' +
                        '                                    <button type="button" class="va-m text-c index_first ml-10" style="width:20px;height:20px;outline:none" onclick="level2_show(this)">+</button>' +
                        '                                    <span class="ml-5 category-name">'+level1List[i].afterCategoryName+'</span>' +
                        '                                    <span class="ml-5 category-id hide">'+level1List[i].afterCategoryId+'</span>' +
                        '                                    <span class="ml-5 category-level hide">'+level1List[i].categoryLevel+'</span>' +
                        '                                </li>' +
                        '                                <li class="f-l text-c" style="width:14%">' +
                        '                                    <span class="show-category-name">'+dealNull(level1List[i].fristCategoryName)+'</span>' +
                        '                                    <i class="Hui-iconfont f-16 c-primary change_first do-edit" style="display: none" onclick="changeFirst(this)">&#xe6df;</i>' +
                        '                                    <b class="remove-showName" style="display: none"><i class="Hui-iconfont c-primary f-16 va-m" onclick="removeFirst(this)">&#xe6a6;</i></b>' +
                        '                                    <input type="text" class="input-text w-80" maxlength="15" style="display: none" value="'+dealNull(level1List[i].fristCategoryName)+'">' +
                        '                                    <span class="edit-btn-box" style="display: none"><i class="Hui-iconfont ml-10 iconsave c-primary f-16 va-m" onclick="saveFirst(this)">&#xe6a7;</i><i class="Hui-iconfont iconcancel c-primary f-16 va-m" onclick="cancelFirst(this)">&#xe6a6;</i></span>' +
                        '                                </li>' +
                        '                                <li class="f-l text-c" style="width:10%"></li>' +
                        '                                <li class="f-l text-c" style="width:13%"></li>' +
                        '                                <li class="f-l text-c" style="width:10%"></li>' +
                        '                                <li class="f-l text-c" style="width:13%"></li>' +
                        '                                <li class="f-l text-c category-show" style="width:8%"><input type="checkbox" class="checkbox level1-checkBox"'+checkedStr1+' disabled></li>' +
                        '                                <li class="f-l text-c category-sort" style="width:6%"><input type="text" class="input-text w-50 level1Sort text-c" oninput = "value=value.replace(/[^0-9]/g,\'\')" onblur="checksort(this,this.value,100)" value="'+level1List[i].showSequence+'" readonly></li>' +
                        '                                <li class="f-l text-c" style="width:14.5%">' +
                        '                                    <input type="button" class="btn btn-secondary size-S radius edit-second-btn  powerButton 230" value="编辑二级品类" onclick="edit_secondcate(this)">' +
                        '                                    <input type="button" class="btn btn-secondary size-S radius save-second-btn" value="保存" style="display:none" onclick="save_secondcate(this)">' +
                        '                                    <input type="button" class="btn size-S radius cancel-second-btn" value="取消" style="display:none" onclick="cancel_secondcate(this)">' +
                        '                                </li>' +
                        '                            </ul>' +
                        '                        </div>' +
                        '                        <div class="level2-box" style="display: none">' + level2Html +
                        '                        </div>' +
                        '                    </div>')
                }
            }
            //权限控制函数
            power()
        }
    });
}

function searchCate(){
    if(isCanEdit&&isCanSearch){
        if ($("#port_type").val() == "PC端"){
            $(".tabBar span:first").html("一级展示设置");
            $(".tabBar span:last").html("次级级展示设置");
        }else{
            $(".tabBar span:first").html("首页品类展示设置");
            $(".tabBar span:last").html("全部品类展示设置");
        }
        searchSubCate();
        searchFirstCate();
    }else if(isCanEdit&&!isCanSearch) {
        layer.msg("存在未保存的首页品类展示设置，请保存或取消后进行查找", {icon: 5, time: 3000});
    }else if(!isCanEdit&&isCanSearch) {
        layer.msg("存在未保存的全部品类展示设置，请保存或取消后进行查找", {icon: 5, time: 3000});
    }else if(!isCanEdit&&!isCanSearch) {
        layer.msg("存在未保存的首页品类展示及全部品类展示设置，请保存或取消后进行查找", {icon: 5, time: 3000});
    }
}
/*------------------------------初始化数据部分开始----------------------*/
/*-------------------------------tab栏配置部分开始--------------------------*/
jQuery.Huitab =function(tabBar,tabCon,class_name,tabEvent,i){
    var $tab_menu=$(tabBar);
    // 初始化操作
    $tab_menu.removeClass(class_name);
    $(tabBar).eq(i).addClass(class_name);
    $(tabCon).hide();
    $(tabCon).eq(i).show();

    $tab_menu.bind(tabEvent,function(){
        $tab_menu.removeClass(class_name);
        $(this).addClass(class_name);
        var index=$tab_menu.index(this);
        $(tabCon).hide();
        $(tabCon).eq(index).show()})}

$(function(){
    $.Huitab("#tab_topnav .tabBar span","#tab_topnav .tabCon","current","click","0")
});
/*-------------------------------tab栏配置部分结束--------------------------*/
/*---------------------一级展示设置编辑按钮配置开始-----------------*/
function editBtn(e){
    if(isCanSearch){
        isCanSearch = false;
        $(".saveBtn").show();
        $(".cancelBtn").show();
        $(e).hide();
        $(".togetherSort").removeAttr("readonly");
    }
}
function saveBtn(e) {
    var isSaveSort = true;
    isCanSearch = true;
    for (var i=0;i<$(".operateTd").length;i++){
        for(var j=i+1;j<$(".operateTd").length;j++){
            if($($(".operateTd")[i]).find(".togetherSort").val()==$($(".operateTd")[j]).find(".togetherSort").val()){
                layer.msg("存在相同的排序，请修改后保存", {icon: 5, time: 3000});
                isSaveSort = false;
                return;
            }
        }
    }
    if(isSaveSort){
        $(".editBtn").show();
        $(".cancelBtn").hide();
        $(e).hide();
        $(".togetherSort").attr("readonly","readonly");
        var sortParams = [];
        for (var i=0;i<$(".operateTd").length;i++){
            sortParams.push({
                frontFirstCategoryId: Number($($(".operateTd")[i]).find(".frontFirstCategoryId").html()),
                showSequence: Number($($(".operateTd")[i]).find(".togetherSort").val()),
            })
        }
        $.ajax({
            contentType: 'application/json',
            url: root.category.category_sortFirstDisplay,
            cache: false,  //禁用缓存
            type: "POST",
            data: JSON.stringify(sortParams),
            success: function (data) {
                if(data.errorCode==0){
                    searchFirstCate();
                }else {
                    layer.msg(data.errorMessage, {icon: 5, time: 3000});
                }
            }
        });
    }
}
function canBtn(e) {
    isCanSearch = true;
    $(".editBtn").show();
    $(".saveBtn").hide();
    $(e).hide();
    $(".togetherSort").attr("readonly","readonly");
    searchFirstCate();
}
/*---------------------一级展示设置编辑按钮配置结束-----------------*/

/*-----------------------弹框编辑部分开始---------------------*/
// 定义需要提交的数据对象
var frameParams = {};
var frontFirstCategoryId = ""; //品类导航聚合主键id
var relationFirstLevelObject = "";//关联的一级分类项，用于获取列表是选中
//显示编辑弹框
function category_edit(thisCategoryList,source) {
    sources=source
    //2018.12.19 铁手需求   湫修改
    //移动端添加品类限制 多选改单选
    if(currenTsource==20){
        $('#show-name').attr('maxlength',5)
        $('#select-box').text('请选择一级品类(单选)')
    }else{
        $('#show-name').attr('maxlength',10)
        $('#select-box').text('请选择一级品类(可多选)')
    }
    frontFirstCategoryId = thisCategoryList.frontFirstCategoryId;
    frameParams = {
        pictureUrl:thisCategoryList.pictureUrl, //图片地址
        displayContent:thisCategoryList.displayContent,  //展示内容
        frontFirstCategoryId:thisCategoryList.frontFirstCategoryId, //品类导航聚合主键id
        relationFirstLevelObject: thisCategoryList.relationFirstLevelObject,//关联品类对象
    }
    $("#category").modal("show");
    $("#myImg").attr({"src":thisCategoryList.pictureUrl});
    $(".show-name").val(thisCategoryList.displayContent);
    var relationFirstLevel = "";
    if(thisCategoryList.relationFirstLevelObject){
        for(var j=0;j<thisCategoryList.relationFirstLevelObject.length;j++){
            relationFirstLevel += "【"+thisCategoryList.relationFirstLevelObject[j].fristCategoryName+"】";
        }
    }else {
        relationFirstLevel = "";
    }
    $(".relation-first-categorys").html(relationFirstLevel);
    relationFirstLevelObject = JSON.stringify(thisCategoryList.relationFirstLevelObject);
    getFirstCateList(relationFirstLevelObject); // 获取所有一级分类列表
}
function close_edit(){
    //清空并关闭弹框
    $("#myImg").attr("src","");
    $("#imgBox").html("");
    var fileInp = document.getElementById('fileUp');
    fileInp.outerHTML = fileInp.outerHTML;
    $(".show-name").val("");
    $("#category .editCateBox ul").html("");
    $(".first_edit").hide();//关闭复选框弹窗
    $("#category").modal("hide");
}
// 获取所有一级分类列表函数
function getFirstCateList(selectCategory) {
    var selectCategory = JSON.parse(selectCategory);
    $.ajax({
        contentType: 'application/json',
        url: root.category.category_listFrontCategory,
        cache: false,  //禁用缓存
        type: "POST",
        data: JSON.stringify({
            categoryLevel: 1,
            source: $("#port_type").val(),
            platform: 10,
            warehouse: 1,
        }),
        success: function (data) {
            if(data.errorCode==0){
                $("#category .editCateBox ul").html("");
                var htmlStr = "";
                var election
                if(currenTsource==20){
                    election='radio'
                }else{
                    election='checkbox'
                }
                for (var i=0;i<data.data.length;i++){
                    var chooseStr = "";
                    if(selectCategory){
                        for(var j=0;j<selectCategory.length;j++){
                            if(selectCategory[j].frontCategoryId == data.data[i].afterCategoryId){
                                chooseStr = "checked";
                                break;
                            }
                        }
                    }else {
                        chooseStr = "";
                    }
                    htmlStr+='<li><input type="'+election+'" name="danm" class="checkbox mr-5" style="margin-top:1px" '+chooseStr+'><span class="cate-name">'+data.data[i].afterCategoryName+'</span><span class="cate-id hide">'+data.data[i].afterCategoryId+'</span></li>';
                }
                $("#category .editCateBox ul").html(htmlStr);
            }
        }
    });
}
// 编辑一级分类按钮
function getSelectedCateBoxShow(){
    $(".first_edit").show();
}

//保存一级分类修改
function getSelectedCate(){
    var categoryHtmlList = $("#category .editCateBox ul li");
    var categorArray = [];
    var relationFiestCategorysHtml = "";
    for(var i=0;i<categoryHtmlList.length;i++){
        if($(categoryHtmlList[i]).find("input")[0].checked){
            categorArray.push({fristCategoryName:$(categoryHtmlList[i]).find(".cate-name").html(),frontCategoryId:$(categoryHtmlList[i]).find(".cate-id").html(),frontFirstCategoryId:frontFirstCategoryId});
            relationFiestCategorysHtml += "【"+$(categoryHtmlList[i]).find(".cate-name").html()+"】";
        }
    }
    $(".relation-first-categorys").html(relationFiestCategorysHtml);
    frameParams.relationFirstLevelObject = categorArray;
    $(".first_edit").hide();
}

//隐藏1级分类编辑弹框
function getSelectedCateBoxHide(){
    getFirstCateList(relationFirstLevelObject);
    $(".first_edit").hide();
}
//https://'+ window.location.host +'
function addBtn() {
    $("#fileUp").trigger('click');
}
var formData = new FormData();
function putDataToPage(e) {
    for (var i = 0; i < e.target.files.length; i++) {
        var file = e.target.files.item(i);
        if (!(/^image\/.*$/i.test(file.type))) {
            continue; //不是图片 就跳出这一次循环
        }
        //实例化FileReader API
        var freader = new FileReader();
        freader.readAsDataURL(file);
        freader.onload = function(e) {
            // $("#myImg").attr("src",e.target.result);

            var data = e.target.result;
            //加载图片获取图片真实宽度和高度
            var img = new Image();
            img.src= data;
            img.onload = function(){
                var width = img.width;
                var height = img.height;
                if(sources==10){
                    //Pc
                    if (width != 50 | height != 24){
                        $.Huimodalalert('图片尺寸限制为：50px*24px',2000);
                        formData.delete("file")
                        var fileUpEl = document.getElementById('fileUp') ;
                        fileUpEl.outerHTML=fileUpEl.outerHTML;
                    }else {
                        $("#imgBox").html("上传中...");
                        formData.append('file', $("#fileUp")[0].files[0]);
                        $.ajax({
                            url: root.inter.imgUpload,
                            cache: false,  //禁用缓存
                            type: "POST",
                            // 告诉jQuery不要去处理发送的数据
                            processData : false,
                            // 告诉jQuery不要去设置Content-Type请求头
                            contentType : false,
                            data: formData,
                            success: function (data) {
                                if(data[0].errorCode==0){
                                    $("#myImg").attr("src",data[0].fullPath);
                                    frameParams.pictureUrl = data[0].fullPath;
                                    $("#imgBox").html("");
                                    layer.msg("上传成功", {icon: 6, time: 3000});
                                    formData.delete("file")
                                    var fileUpEl = document.getElementById('fileUp') ;
                                    fileUpEl.outerHTML=fileUpEl.outerHTML;
                                } else {
                                    layer.msg(data[0].errorInfo, {icon: 5, time: 3000});
                                    var fileUpEl = document.getElementById('fileUp') ;
                                    fileUpEl.outerHTML=fileUpEl.outerHTML;
                                }
                            }
                        })
                    }
                }else {
                    //APP
                    if (width != 108 | height != 108){
                        $.Huimodalalert('图片尺寸限制为：108*108',2000);
                        formData.delete("file")
                        var fileUpEl = document.getElementById('fileUp') ;
                        fileUpEl.outerHTML=fileUpEl.outerHTML;
                    }else {
                        $("#imgBox").html("上传中...");
                        formData.append('file', $("#fileUp")[0].files[0]);
                        $.ajax({
                            url: root.inter.imgUpload,
                            cache: false,  //禁用缓存
                            type: "POST",
                            // 告诉jQuery不要去处理发送的数据
                            processData : false,
                            // 告诉jQuery不要去设置Content-Type请求头
                            contentType : false,
                            data: formData,
                            success: function (data) {
                                if(data[0].errorCode==0){
                                    $("#myImg").attr("src",data[0].fullPath);
                                    frameParams.pictureUrl = data[0].fullPath;
                                    $("#imgBox").html("");
                                    layer.msg("上传成功", {icon: 6, time: 3000});
                                    formData.delete("file")
                                    var fileUpEl = document.getElementById('fileUp') ;
                                    fileUpEl.outerHTML=fileUpEl.outerHTML;
                                } else {
                                    layer.msg(data[0].errorInfo, {icon: 5, time: 3000});
                                    var fileUpEl = document.getElementById('fileUp') ;
                                    fileUpEl.outerHTML=fileUpEl.outerHTML;
                                }
                            }
                        })
                    }
                }


            };
        }
    }

}
function savecate_edit() {
    frameParams.displayContent = $(".show-name").val();
    console.log(frameParams)
    if(frameParams.displayContent==""){
        layer.msg("展示内容不能为空", {icon: 5, time: 3000});
    }else if(frameParams.pictureUrl==""){
        layer.msg("图标不能为空", {icon: 5, time: 3000});
    }else if(frameParams.relationFirstLevelObject==null){
        layer.msg("关联一级分类", {icon: 5, time: 3000});
    }else {
        $.ajax({
            contentType: 'application/json',
            url: root.category.category_saveFrontFirstCategory,
            cache: false,  //禁用缓存
            type: "POST",
            data: JSON.stringify(frameParams),
            success: function (data) {
                if(data.errorCode==0){
                    searchFirstCate();
                    $("#category").modal("hide");
                }else {
                    layer.msg(data.errorMessage, {icon: 5, time: 3000});
                }

            }
        });
    }

}
/*-----------------------弹框编辑部分结束---------------------*/
